//***********************************************************************
//	File:		Game.h
//	Author:		
//	Course:		SGP 1405
//	Purpose:	Game class will run game logic
//***********************************************************************
//***********************************************************************
//	Purposfully left blank for all comments regarding this file 
//	
//	
//	
//***********************************************************************




#pragma once
#include "../SGD Wrappers/SGD_Declarations.h"
#include "../GameStates/IGameState.h"
#include "../source/BitmapFont.h"

class Game
{
public:
	// Dynamic Singleton
	static Game*		GetInstance			(void); 
	static void			DeleteInstance		(void); 


		   bool			Initialize			(float screenWidth, float screenHeight); 
		   int			Update				(void); 
		   void			Terminate			(void); 

		   float			GetScreenWidth(void) const	{ return m_fScreenWidth; }
		   float			GetScreenHeight(void) const	{ return m_fScreenHeight; }

		   // Font Accessor:
		   BitmapFont* GetFont(void) const	{ return m_pFont; }

		   // Menu Joystick cooldown accessors 
		   bool GetController_0_Left_Joystick_Cooldown(void) { return m_bController_0_Left_Joystick_Cooldown; }
		   bool GetController_1_Left_Joystick_Cooldown(void) { return m_bController_1_Left_Joystick_Cooldown; }

		   // Menu Joystick cooldown mutators 
		   void SetController_0_Left_Joystick_Cooldown(bool jsc0) { m_bController_0_Left_Joystick_Cooldown = jsc0; }
		   void	SetController_1_Left_Joystick_Cooldown(bool jsc1) { m_bController_1_Left_Joystick_Cooldown = jsc1; }

		   // Pertinant player info 
		   int GetP1Lives(void) const { return m_nP1Lives; }
		   int GetP2Lives(void) const { return m_nP2Lives; }
		   int GetP1Score(void) const { return m_nP1Score; }
		   int GetP2Score(void) const { return m_nP2Score; }

		   // Mutators for pertinant player info 
		   void SetP1Lives(int p1l) { m_nP1Lives = p1l; }
		   void SetP2Lives(int p2l) { m_nP2Lives = p2l; }
		   void SetP1Score(int p1s) { m_nP1Score = p1s; }
		   void SetP2Score(int p2s) { m_nP2Score = p2s; }

		   //When loading, what level am I on
		   int GetWhatLevel(void) const { return m_nWhatLevel; }

		   void SetWhatLevel(int wl) { m_nWhatLevel = wl; }

		   // Accessors for Cursor
		   int GetSavesCursor(void) const { return m_nSavesCursor; }
		   int GetSavesCursorMax(void) const { return m_nSavesCursorMax; }

		   // Mutator for Cursor 
		   void SetSavesCursor(int sc) { m_nSavesCursor = sc; }
		   void SetSavesCursorMax(int scm) { m_nSavesCursorMax = scm; }

		   /**********************************************************/
		   // Game State Machine:
		   //	- can ONLY be called by the state's Input, Update, or Render methods!!!
		   void ChangeState(IGameState* pNewState);

		   //Asset Accessors
		   SGD::HAudio GetBackgroundMus() const  { return m_hBackgroundMus; }
		   SGD::HAudio GetSampleSfx() const { return m_hSampleSfx; }
		   SGD::HAudio GetSniperBulletSfx() const { return m_hSniperBulletSfx; }

		   //Visual Asset Accessors 
		   SGD::HTexture GetGroundPlayerImg() const { return m_hPlayerImg; }
		   SGD::HTexture GetAirPlayerImg(void) const { return m_hPlayerAirImg; }
		   SGD::HTexture GetBulletImg(void) const { return m_hBulletImg; }
		   SGD::HTexture GetImage( int type ) const;

		   enum Images { ANKLEBITER,};

private:
	//Singleton Pointer
	static		Game*			s_pInstance;


	Game()							= default;
	~Game()							= default;
	Game(const Game&)				= delete; 
	Game& operator =(const Game&)	= delete;

	/**********************************************************/
	// SGD Wrappers
	SGD::AudioManager*		m_pAudio = nullptr;
	SGD::GraphicsManager*	m_pGraphics = nullptr;
	SGD::InputManager*		m_pInput = nullptr;

	/**********************************************************/
	// Screen Size
	float					m_fScreenWidth = 1;
	float					m_fScreenHeight = 1;


	/**********************************************************/
	// Game Font
	BitmapFont*				m_pFont = nullptr;


	/**********************************************************/
	// Current Game State
	IGameState*				m_pCurrState = nullptr;


	/**********************************************************/
	// Game Time
	unsigned long			m_ulGameTime = 0;

	/**********************************************************/
	// Pause 
	bool				    m_bIsPaused = 0;

	/**********************************************************/
	// Keeping our joysticks under control
	bool				    m_bController_0_Left_Joystick_Cooldown = false;
	bool					m_bController_1_Left_Joystick_Cooldown = false; 

	/**********************************************************/
	// Assets

	// Visual 
	SGD::HTexture m_hPlayerImg = SGD::INVALID_HANDLE;
	SGD::HTexture m_hPlayerAirImg = SGD::INVALID_HANDLE;
	SGD::HTexture m_hBulletImg = SGD::INVALID_HANDLE; 
	SGD::HTexture m_hAnklebiterImg = SGD::INVALID_HANDLE;
	SGD::HTexture m_hBasherImg = SGD::INVALID_HANDLE;

	// Audio
	SGD::HAudio m_hBackgroundMus = SGD::INVALID_HANDLE;
	SGD::HAudio m_hSampleSfx = SGD::INVALID_HANDLE; 
	SGD::HAudio m_hSniperBulletSfx = SGD::INVALID_HANDLE; 

	// Check for FullScreen
	bool m_bFullScreen = true;

	// Hold on to pertinant player info for saving and loading 
	int m_nP1Lives;
	int m_nP2Lives;

	int m_nP1Score;
	int m_nP2Score;

	/**********************************************************/
	// Game Saves Cursor
	int m_nSavesCursor = 0;
	int m_nSavesCursorMax = 2;

	/**********************************************************/
	// What level am I on
	int m_nWhatLevel = -1;

	
};

